/**
 * Author@ Cheng Feitian
 * Date: 2021-4-4
 * Description: 制作饮品
 */

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
const int maxn = 1024;

class AbstractDrinking
{
public:
    //煮水
    virtual void Boil() = 0;

    //冲泡
    virtual void Brew() = 0;

    //导入杯中
    virtual void PourIntoCup() = 0;

    //加入辅料
    virtual void PutSomething() = 0;

    //制作饮品
    void makeDrink()
    {
        Boil();
        Brew();
        PourIntoCup();
        PutSomething();
    }
};

//制作Coffee
class Coffee : public AbstractDrinking
{
public:
    //煮水
    virtual void Boil()
    {
        cout << "煮水中！" << endl;
    }

    //冲泡
    virtual void Brew()
    {
        cout << "冲泡Coffee！" << endl;
    }

    //导入杯中
    virtual void PourIntoCup()
    {
        cout << "倒入杯中！" << endl;
    }

    //加入辅料
    virtual void PutSomething()
    {
        cout << "加入糖！" << endl;
    }
};

class Tea : public AbstractDrinking
{
public:
    //煮水
    virtual void Boil()
    {
        cout << "煮水中！" << endl;
    }

    //冲泡
    virtual void Brew()
    {
        cout << "冲泡茶叶！" << endl;
    }

    //导入杯中
    virtual void PourIntoCup()
    {
        cout << "倒入杯中！" << endl;
    }

    //加入辅料
    virtual void PutSomething()
    {
        cout << "加入柠檬！" << endl;
    }
};

void doWork(AbstractDrinking * abs){
    abs->makeDrink();
    delete abs; //释放
}

void test01()
{
    // AbstractDrinking *coffee = new Coffee;
    // coffee->makeDrink();
    // delete coffee;

    // AbstractDrinking *tea = new Tea;
    // tea->makeDrink();
    // delete tea;
    doWork(new Coffee);
    doWork(new Tea);
}

int main()
{
    test01();
    return 0;
}
